﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@

@* 模型绑定，可以将C#对象直接传递到视图。 @model 指令告诉 Razor 该视图要绑定到哪个模型。模型通过 Model 属性进行访问。 *@
@model TodoViewModel
@* @using Humanizer *@

@{
    ViewData["Title"] = "Manage your todo list";
}

<div class="panel panel-default todo-panel">
    <div class="panel-heading">@ViewData["Title"]</div>

    <table class="table table-hover">
        <thead>
            <tr>
                <td>&#x2714;</td>
                <td>Item</td>
                <td>Due</td>
            </tr>
        </thead>

        @if (Model != null && Model.Items != null)
        {
            foreach (var item in Model.Items)
            {
                <tr>
                    <td>
                        <form asp-action="MarkDone" method="post">
                            <input type="checkbox" class="done-checkbox">
                            <input type="hidden" name="id" value="@item.Id" />
                        </form>
                    </td>
                    <td>@item.Title</td>
                    <td>@item.DueAt</td>
                    @* <td>@item.DueAt.Humanize()</td> *@
                </tr>
            }
        }
    </table>

    <div class="panel-footer add-item-form">
        <!-- TODO: Add item form -->
        @await Html.PartialAsync("AddItemPartial", new TodoItem())
    </div>
</div>